﻿//-----------------------------------------------------------------------
// <copyright file="IMergeCellInternal.cs" company="LMT">
//     Copyright (c) by La Minh Thuận.
// </copyright>
// <author>thuanla1985@hotmail.com</author>
//-----------------------------------------------------------------------
namespace LMT.Forms
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Text;
    using System.Windows.Forms;
    
    /// <summary>
    /// A ColumnCollection for MergeGridView control.
    /// </summary>
    [ListBindable(false)]
    public class MergeGridViewColumnCollection : DataGridViewColumnCollection
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="MergeGridViewColumnCollection"/> class.
        /// </summary>
        /// <param name="gridView">The grid view.</param>
        public MergeGridViewColumnCollection(MergeGridView gridView) : base(gridView)
        {
        }

        /// <summary>
        /// Gets the <see cref="System.Windows.Forms.DataGridViewColumn"/> with the specified column name.
        /// </summary>
        /// <param name="columnName">The name of column.</param>
        /// <value></value>
        public new MergeGridViewColumn this[string columnName]
        {
            get
            {
                if (columnName == null)
                {
                    throw new ArgumentNullException("columnName");
                }

                int count = this.Count;
                for (int i = 0; i < count; i++)
                {
                    MergeGridViewColumn column = (MergeGridViewColumn)base[i];
                    if (string.Equals(column.Name, columnName, StringComparison.OrdinalIgnoreCase))
                    {
                        return column;
                    }
                }

                return null;
            }
        }

        /// <summary>
        /// Gets the <see cref="LMT.Forms.MergeGridViewColumn"/> at the specified index.
        /// </summary>
        /// <param name="index">index of column.</param>
        public new MergeGridViewColumn this[int index]
        {
            get
            {
                return (MergeGridViewColumn)base[index];
            }
        }
    }
}
